<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/2/23
 * Time: 12:44
 */

namespace Check;


class Check
{
    static function int($int = '', $sizeMax = 0, $sizeMin = 0) {
        if (count($int) > $sizeMax || count($int) < $sizeMin) {
            return $int;
        } else {
            return 0;
        }
    }

    static function string($string = '', $sizeMax = 0, $sizeMin = 0)
    {
        if (strlen($string) > $sizeMax || strlen($string) < $sizeMin) {
            return $string;
        } else {
            return 0;
        }
    }

    static function float($float = '', $size = 0) {
//        todo: a regular expressions.
    }

    static function isEmail($email = '') {
        if (preg_match('/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/', $email)) {
            return true;
        } else {
            return false;
        }
    }

    static function isNickname($nickname = '') {
        if (strlen($nickname) < 16) {
            return true;
        } else {
            return false;
        }
    }

    static function post($post = [])
    {

        foreach ($post as $key => $value) {
            $postResult[$key] = stripslashes($post[$key]);
        }
        return $postResult;
    }
}